package org.theSeed.fileContractAliImpl.pojo.prop;

import cn.hutool.core.util.ObjectUtil;
import com.google.common.base.Preconditions;
import lombok.Getter;
import lombok.Setter;
import org.theSeed.fileContract.contract.FileContract;
import org.theSeed.fileContract.pojo.prop.FileConfigProp;
import org.theSeed.fileContractAliImpl.contract.impl.FileContractAliImpl;

/**
 * 阿里云文件上传配置
 */
@Getter
@Setter
public class FileConfigAliProp extends FileConfigProp {
    /**
     * 域名
     */
    private String endpoint = "oss-cn-hangzhou.aliyuncs.com";

    /**
     * 桶名称
     */
    private String bucketName;
    /**
     * 区域
     */
    private String region = "cn-hangzhou";

    /**
     * key
     */
    private String accessKeyId;

    /**
     * 秘钥
     */
    private String accessKeySecrect;

    @Override
    public void checkImplParam() {
        Preconditions.checkArgument(ObjectUtil.isNotEmpty(getEndpoint()),"桶名称");
        Preconditions.checkArgument(ObjectUtil.isNotEmpty(getEndpoint()),"域名不能为空");
        Preconditions.checkArgument(ObjectUtil.isNotEmpty(getRegion()),"区域不能为空");
        Preconditions.checkArgument(ObjectUtil.isNotEmpty(getAccessKeyId()),"aliOssKey不能为空");
        Preconditions.checkArgument(ObjectUtil.isNotEmpty(getAccessKeySecrect()),"aliOss秘钥不能为空");
    }

    @Override
    public FileContract createFileContract(String contractTypeInstance, Long chipFileSize) {
        return new FileContractAliImpl(contractTypeInstance,this,chipFileSize);
    }
}
